<template>
  <div class="app-container">
    <div class="searchBox">
      <el-form :inline="true">
        <el-form-item label="标题：">
          <el-input v-model="search.title" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="消息类型：">
          <el-select v-model="search.messageType" placeholder="请选择">
            <el-option
              v-for="item in controlData.messageTypes"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="searchQuery">查询</el-button>
          <el-button type="info" @click="search = {}; searchQuery();">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <qm-table :data="query" keyProp="logId" 
    :formValidate="defaultFormValidate" 
    isCustomForm :showAdd="false" 
    :menuOptions="{ width: 100 }"
    :showEdit="false" 
     menuType="text"
     useFormPage
       :formPage="{
        create: '/message/sysMessageLog/create',
        view: '/message/sysMessageLog/view',
        edit: '/message/sysMessageLog/create'
            }"
    >
      <qm-table-column field="messageType" sortable="true">消息类型</qm-table-column>
      <qm-table-column field="title" sortable="true">消息标题</qm-table-column>
      <qm-table-column field="receiver" sortable="true">接收人账号</qm-table-column>
      <!--<qm-table-column field="status" sortable="true">应用系统</qm-table-column>-->
      <qm-table-column field="status" sortable="true" :renderFunc="renderSendStatus">发送状态</qm-table-column>
      <qm-table-column field="readStatus" sortable="true" :renderFunc="renderReadStatus">阅读状态</qm-table-column>
      <qm-table-column field="retryCount" sortable="true">次数</qm-table-column>
      <qm-table-column field="startTime" width="180px" sortable="true">发送时间</qm-table-column>
      <qm-table-column field="endTime" width="180px" sortable="true">完成时间</qm-table-column>

      <template v-slot:form="{ models, controlData }">
        <create ref="create" :models="models" :controlData="controlData"></create>
      </template>
    </qm-table>
  </div>
</template>

<script>
import Controller from "@/libs/framework/controller";
import Create from "./create";
export default class Instance extends Controller {
  onBeforeInit() {
    this.urls = {
			model: "/message/sysMessageLog/getListModel",
      query: "/message/sysMessageLog/query",
      save: "/message/sysMessageLog/save",
      delete: "/message/sysMessageLog/delete",
      entity: "/message/sysMessageLog/getEntity",
    };
  }

  mixin() {
    return {
      components: {
        Create,
      },
      data() {
        return {};
      },
      methods: {
        renderSendStatus(data, row, column) {
          let find = this.super.$util.find(
            this.controlData.sendStatus,
            (item) => {
              return item.value === data;
            }
          );
          return (find || {}).key;
        },
        renderReadStatus(data, row, column) {
          let find = this.super.$util.find(
            this.controlData.readStatus,
            (item) => {
              return item.value === data;
            }
          );
          return (find || {}).key;
        },
      },
    };
  }
}
</script>

<style scoped lang="scss">
</style>
